<template>
  <div class="">
    <div class="crumbs">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item
          ><i class="el-icon-lx-copy"></i> tab选项卡</el-breadcrumb-item
        >
      </el-breadcrumb>
    </div>
    <div class="container">
      <el-tabs v-model="message">
        <el-tab-pane :label="`未读消息(${tableData.length})`" name="first">
          <el-table
            ref="multipleTableRef"
            :data="tableData"
            style="width: 100%"
            @selection-change="handleSelectionChange"
          >
            <el-table-column label="标题名称" width="200">
              <template #default="scope">
                <a @click="tiao(scope.row.id)" style="color: blue">{{
                  scope.row.titlename
                }}</a>
              </template>
            </el-table-column>
            <el-table-column
              property="issuetime"
              label="发布时间"
              width="250"
            />
          </el-table>
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="pageindex"
            :page-sizes="[50, 100, 150, 200]"
            :page-size="pageize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="count"
          >
          </el-pagination>
          <div class="handle-row">
            <el-button type="primary">全部标为已读</el-button>
          </div>
        </el-tab-pane>
        <!-- <el-tab-pane :label="`已读消息(${state.read.length})`" name="second">
          <template v-if="message === 'second'">
            <el-table
              :data="state.read"
              :show-header="false"
              style="width: 100%"
            >
              <el-table-column>
                <template #default="scope">
                  <span class="message-title">{{ scope.row.title }}</span>
                </template>
              </el-table-column>
              <el-table-column prop="date" width="150"></el-table-column>
              <el-table-column width="120">
                <template #default="scope">
                  <el-button type="danger" @click="handleDel(scope.$index)"
                    >删除</el-button
                  >
                </template>
              </el-table-column>
            </el-table>
            <div class="handle-row">
              <el-button type="danger">删除全部</el-button>
            </div>
          </template>
        </el-tab-pane> -->
      </el-tabs>
    </div>
  </div>
</template>

<script>
import { ref,reactive } from "vue";
import { GetSiganalr } from "../api/Inform.js";
export default {
  name: "tabs",
  setup() {
    const message = ref("first");
    const state = ref([]);
    const tableData = ref([]);
    const formInline = reactive({
      pageindex: 1,
      pagesize: 10,
      TitleName: "",
      Issuer: "",
      IssueTime: "",
    });
    const count = ref(0);
    const handleRead = (index) => {
      const item = state.unread.splice(index, 1);
      console.log(item);
      state.read = item.concat(state.read);
    };
    const handleDel = (index) => {
      const item = state.read.splice(index, 1);
      state.recycle = item.concat(state.recycle);
    };
    const signalRShow = () => {
      GetSiganalr(formInline).then((ros) => {
        tableData.value = ros.items;
        count.value = ros.totalCount;
      });
    };
    signalRShow();

    return {
      message,
      state,
      count,
      tableData,
      formInline,
      handleRead,
      handleDel,
      signalRShow,
    };
  },
};
</script>

<style>
.message-title {
  cursor: pointer;
}
.handle-row {
  margin-top: 30px;
}
</style>

